<template>
  <PageContainer>
    <view class="container">
      <Header :title="globalConfig?.name" />
      <image
        class="w-full"
        src="https://hb-saas.obs.cn-south-1.myhuaweicloud.com/mall/saas/bo_publicity.png"
        mode="widthFix"
      />
      <TButtonGroup>
        <TButton
          class="gutter-btn"
          custom-class="br-22"
          text="发布供需"
          type="primary"
          @click="handleCreate"
        />
        <TButton
          v-if="routeQuery?.type === 'Invitation'"
          class="gutter-btn"
          text="前往供需广场"
          type="primary"
          custom-class="br-22"
          @click="handleToSquare"
        />
      </TButtonGroup>
    </view>
  </PageContainer>
</template>

<script lang="ts" setup>
  /* boPromotionalPage  */
  import { setPublicity } from '@/api';
  import Header from '@/components/Header/index.vue';
  import PageContainer from '@/components/PageContainer/index.vue';
  import TButtonGroup from '@/components/TButtonGroup/index.vue';
  import TButton from '@/components/TButtonGroup/TButton.vue';
  import { ReleaseTypeEnum } from '@/enums/businessOpportunitiesEnum';
  import { BusinessFunctionTypeEnum } from '@/enums/publicModuleEnum';
  import { onLoad, redirectTo } from '@/router';
  import type { BoPromotionalPage } from '@/router/types/modules';
  import { useAppStore } from '@/store/modules/app';
  import { ref } from 'vue';

  const { globalConfig } = useAppStore();
  const routeQuery = ref<BoPromotionalPage>();
  onLoad<'boPromotionalPage'>((op) => {
    routeQuery.value = op;
    setPublicity({ type: BusinessFunctionTypeEnum.BO });
  });

  function handleCreate() {
    redirectTo({
      name: 'releaseBusinessOpportunities',
      options: {
        releaseType: ReleaseTypeEnum.member,
        shareKey: routeQuery.value?.shareKey,
      },
    });
    // redirectTo({
    //   name: 'myBusinessOpportunities',
    //   options: {
    //     shareKey: routeQuery.value?.shareKey,
    //   },
    // });
  }

  function handleToSquare() {
    redirectTo({ name: 'supplyDemandSquare' });
  }
</script>

<style lang="scss" scoped></style>
